<template>
		<view class="notice-item">
			<view class="list-cell b-b m-t" @click="portrait" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">个人资料</text>
				<image class="cell-tip caty-imge" :src="list.avatar"></image>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<view class="list-cell b-b m-t" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">昵称</text>
				<text class="cell-tip">{{list.nick}}</text>
				<text class="cell-more yticon"></text>
			</view>
			<view class="list-cell b-b m-t" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">ID</text>
				<text class="cell-tip">{{list.userId}}</text>
				<text class="cell-more yticon"></text>
			</view>
	</view>
</template>

<script>
	import roles from '@/http/roles.js'
	import oss from '@/http/oss.js'
	export default {
		data() {
			return {
                 list:[],
				 Aliyun:{}
			}
		},
		onLoad(){
			this.loacheck()
			this.loasster()
		},
		methods:{
           async loacheck(){
			   const res = await roles.userinfo()
			   this.list = res.data
		   },
		   // 阿里云信息获取
		   async loasster(){
			   const {data} = await oss.ossmessage({'ossGroup':'UserAvatar'})
			   this.Aliyun = data
			   console.log(this.Aliyun)
		   },
		    portrait(){
			     wx.chooseImage({  //从本地相册选择图片或使用相机拍照
			            count: 1, // 默认9	
			            sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
			            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
			            success:async(res) =>{
							let tempFilePaths = res.tempFilePaths[0]
			                        wx.uploadFile({
										 url: this.Aliyun.accessUrl,//上传的路径
										    filePath: tempFilePaths,
										    name: this.Aliyun.bucketName,
									     formData: {
									        name: tempFilePaths,
									        key: "${filename}",//上传图片的名字和路径（默认路径根目录，自定义目录：xxx/xxx.png）
									        policy: this.Aliyun.endpoint,
									        OSSAccessKeyId: this.Aliyun.accessKeyId,
									        success_action_status: "200",
											secretToken:this.Aliyun.secretToken
									      },
										  success:(ress)=>{
											  console.log('qe',ress)
										  }
									})
			                     
			                     }
			                   })
		   },
		   // 修改跳转
		   navTo(url){
			   uni.navigateTo({
			   	url
			   })  
		   }
		}
	}
</script>

<style lang='scss'>
	page {
		background-color: #f7f7f7;
		padding-bottom: 30upx;
	}
.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
	.caty-imge{
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		transform: translateY(20%);
	}
</style>
